import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DesignProjectVO, DesignProjectForm, DesignProjectQuery,PauseProjectDesignForm } from '@/api/sj/designProject/types';

/**
 * 查询设计任务项目列表
 * @param query
 * @returns {*}
 */

export const listDesignProject = (query?: DesignProjectQuery): AxiosPromise<DesignProjectVO[]> => {
  return request({
    url: '/sj/designProject/list',
    method: 'get',
    params: query
  });
};



/**
 * 查询设计任务项目详细
 * @param id
 */
export const getDesignProject = (id: string | number): AxiosPromise<DesignProjectVO> => {
  return request({
    url: '/sj/designProject/' + id,
    method: 'get'
  });
};

/**
 * 新增设计任务项目
 * @param data
 */
export const addDesignProject = (data: DesignProjectForm) => {
  return request({
    url: '/sj/designProject',
    method: 'post',
    data: data
  });
};

/**
 * 修改设计任务项目
 * @param data
 */
export const updateDesignProject = (data: DesignProjectForm) => {
  return request({
    url: '/sj/designProject',
    method: 'put',
    data: data
  });
};

/**
 * 删除设计任务项目
 * @param id
 */
export const delDesignProject = (id: string | number | Array<string | number>) => {
  return request({
    url: '/sj/designProject/' + id,
    method: 'delete'
  });
};

/**
 * 开始任务
 * @param id
 * */
export const startDesignProject = (id: string | number) => {
  return request({
    url: `/sj/designProject/start/${id}`,
    method: 'get'
  });
};

/**
 * 暂停任务
 * @param id,remark
 * */
export const pauseDesignProject = (data: PauseProjectDesignForm) => {
  return request({
    url: `/sj/designProject/suspend`,
    data: data,
    method: 'post'
  });
};

/**
 * 结束任务
 * @param id,remark
 * */
export const finishDesignProject = (data: PauseProjectDesignForm) => {
  return request({
    url: `/sj/designProject/stop`,
    data: data,
    method: 'post'
  });
};

/**
 * 用时详情
 * */
export const checkProjectTime = (id: string | number) => {
  return request({
    url: `/sj/designProject/getRecordDetail/${id}`,
    method: 'get'
  });
};

/**
 * 查看进行中的任务
 * @param id
 * */
export const checkDoingProject = () => {
  return request({
    url: `/sj/designProject/doing`,
    method: 'get'
  });
};

/**
 * 结束今日
 * */
export const stopToday = () => {
  return request({
    url: `/sj/designProject/stopToday`,
    method: 'get'
  });
};